/*
  
  An ActorMessage encapsulates a command and a serializable message for transmission
  over the network between MulticastActorGroup objects.  It extends ObjectMessage, 
  because ActorGroup objects are expecting ObjectMessages, and by doing so ActorMessage's
  inherit all the necessary traits to be used in our system.  We initialize ObjectMessage
  with MessageType.RPC_MESSAGE, because it is not a control message.  We also send the
  constructor the payload, msg, itself.  Finally, we send it a null source, because, for
  now, we don't care who sent the ActorMessage itself.
  
  **/

package scala.actors.multicast.message

import edu.ucla.cs.rpc.multicast.network.message.ObjectMessage
import edu.ucla.cs.rpc.multicast.network.message.Message.MessageType

import java.io.Serializable
import java.net.SocketAddress

abstract class ActorCommand
case object Bang extends ActorCommand
case object BangBang extends ActorCommand
case object BangMark extends ActorCommand
case object Forward extends ActorCommand

case class ActorMessage(command: ActorCommand, msg: Serializable, source: SocketAddress) extends ObjectMessage(MessageType.RPC_MESSAGE, msg, source) {
  
  def getCommand: ActorCommand = command
  
  def getMsg: Serializable = msg
  
  override def toString: String = "(" + command + ", " + msg + ")"
}
